package com.JUC;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class JUC06_Callable {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        // 调用线程
        FutureTask futureTask = new FutureTask(new MyThread());
//        FutureTask futureTask = new FutureTask(
//                () -> {System.out.println("==== 进入 ====");
//                    return 1024;
//                });
        new Thread(futureTask,"Thread_A").start();
        // 获得返回值
        System.out.println(futureTask.get());
    }
}
// Callable 后的泛型写什么类型，就返回什么类型
class MyThread implements Callable<Integer>{
    @Override
    public Integer call() throws Exception {
        System.out.println("==== 进入 ====");

        return 1024;
    }
}
